package com.hq.fxh.Utils;

import android.app.Activity;
import android.content.Context;
import android.content.SharedPreferences;

/**
 * /**
 *
 * @author 薛
 * @ClassName
 * @Description :
 * @Created 2017/8/31
 * @Email xlwenhao1858@sina.com
 */


public class SharedPreferenceUtils {

    private Context context;

    public SharedPreferenceUtils(Context context) {
        this.context = context;
    }

    public static void setSpaceImageUrl(Context context, String companyName) {
        SharedPreferences sharedPreferences = context.getSharedPreferences("SpaceImagePersionCardUrl", Activity.MODE_PRIVATE);
        if (sharedPreferences != null) {
            sharedPreferences.edit().putString("SpaceImageUrl", companyName).apply();
        }
    }

    public static String getSpaceImageUrl(Context context) {
        SharedPreferences sharedPreferences = context.getSharedPreferences("SpaceImagePersionCardUrl", Activity.MODE_PRIVATE);
        if (sharedPreferences != null) {
            String companyName = sharedPreferences.getString("SpaceImageUrl", "");
            return companyName;
        } else {
            return "";
        }
    }

    public static int getMemberId(Context context) {
        SharedPreferences sharedPreferences = context.getSharedPreferences("memberId", Activity.MODE_PRIVATE);
        if (sharedPreferences != null) {
            int memberId = sharedPreferences.getInt("memberId", 0);
            if(memberId==0)return 14227;
            return memberId;
        } else {
            return 14227;
        }
    }



    public int getMemberId() {
        SharedPreferences sharedPreferences = context.getSharedPreferences("memberId", Activity.MODE_PRIVATE);
        if (sharedPreferences != null) {
            int memberId = sharedPreferences.getInt("memberId", 0);
            return memberId;
        } else {
            return 0;
        }
    }

    public static String getCompanyName(Context context) {
        SharedPreferences sharedPreferences = context.getSharedPreferences("memberId", Activity.MODE_PRIVATE);
        if (sharedPreferences != null) {
            String companyName = sharedPreferences.getString("CompanyName", "杭州嗨趣网络科技有限公司");
            return companyName;
        } else {
            return "小谢";
        }
    }
    public static int getIs_active(Context context) {//是否激活 0未激活
        SharedPreferences sharedPreferences = context.getSharedPreferences("memberId", Activity.MODE_PRIVATE);
        if (sharedPreferences != null) {
            int is_active = sharedPreferences.getInt("is_active", 1);
            return is_active;
        } else {
            return 1;
        }
    }


    //是否悬浮
    public static void setIsflout(Context context, int isflout) {
        SharedPreferences sharedPreferences = context.getSharedPreferences("memberId", Activity.MODE_PRIVATE);
        if (sharedPreferences != null) {
            sharedPreferences.edit().putInt("isflout", isflout).apply();
        } else {
            return;
        }
    }
    public static void setIsShowAgreement(boolean IsShowAgreement, Context context) {
        SharedPreferences sharedPreferences = context.getSharedPreferences("save", Activity.MODE_PRIVATE);
        if (sharedPreferences != null) {
            sharedPreferences.edit().putBoolean("IsShowAgreement", IsShowAgreement).apply();
        }
    }

    public static int getIsflout(Context context) {
        SharedPreferences sharedPreferences = context.getSharedPreferences("memberId", Activity.MODE_PRIVATE);
        if (sharedPreferences != null) {
            int isflout = sharedPreferences.getInt("isflout", 1);
            return isflout;
        } else {
            return 1;
        }
    }


    public static boolean getIsShowAgreement(Context context) {//默认false,展示过一次设为true;false展示，true不展示
        SharedPreferences sharedPreferences = context.getSharedPreferences("save", Activity.MODE_PRIVATE);
        if (sharedPreferences != null) {
            boolean IsShowAgreement = sharedPreferences.getBoolean("IsShowAgreement", false);//IsShowAgreement
            return IsShowAgreement;
        }
        return false;
    }


    public static int getIsCompany(Context context) {
        SharedPreferences sharedPreferences = context.getSharedPreferences("memberId", Activity.MODE_PRIVATE);
        if (sharedPreferences != null) {
            int isCompany = sharedPreferences.getInt("isCompany", 0);
            return isCompany;
        } else {
            return 0;
        }
    }

}
